package com.ocp.socket.busi.userinfo.service.impl;

import com.example.app.api.userinfo.bean.User;
import com.ocp.socket.busi.userinfo.service.IUserInfoService;
import com.ocp.socket.common.enums.CacheKeyEnum;
import com.ocp.socket.common.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author : lichong
 * @description :
 * @Date Create in 13:23 2019/3/9
 * @Modified By :
 **/
@Service("userInfoService")
public class UserInfoServiceImpl implements IUserInfoService {

    @Autowired
    private RedisUtil redisUtil;

    /**
     * 检查用户session
     * @param openId       用户的唯一标识
     * @param sessionId     当前的socket sessionId
     * @return
     */
    @Override
    public User getUserInfo(String openId, Long sessionId) {
        String key = CacheKeyEnum.USER_INFO_KEY.getCacheKey() + openId;
        //获取用户的缓存信息
        User user = redisUtil.get(key, User.class);
        if (user == null) {
            return null;
        }
        return user;
    }
}
